export const mergeValues: any = ref({
  id: 0,
  name: '',
  config: {
    wechat: {
      default: {
        status: '0',
        mch_id: '',
        apiv3Key: '',
        mch_secret_key: '',
        mch_secret_cert: '',
        mch_public_cert_path: '',
        notify_url: '',
        mp_app_id: '',
        mini_app_id: '',
        app_id: '',
        serial_no: '',
      },
    },
    alipay: {
      default: {
        status: '0',
        app_id: '',
        app_secret_cert: '',
        app_public_cert_path: '',
        alipay_public_cert_path: '',
        alipay_root_cert_path: '',
        return_url: '',
        notify_url: '',
      },
    },
    unipay: {
      default: {
        status: '0',
        mch_id: '',
        mch_cert_password: '',
        mch_cert_path: '',
        unipay_public_cert_path: '',
        return_url: '',
        notify_url: '',
      },
    },
    logger: {
      enable: false,
      file: '',
      level: 'info',
      type: 'single',
      max_file: 30,
    },
    http: {
      timeout: 5,
      connect_timeout: 5,
    },
  },
});

export const wechatScheam = [
  {
    component: 'Switch',
    defaultValue: '',
    dependencies: {
      trigger: (values: any) => {
        mergeValues.value.config.wechat.default = {
          ...mergeValues.value.config.wechat.default,
          ...values,
        };
      },
      // 随意一个字段改变时，都会触发
      triggerFields: [
        'status',
        'mch_id',
        'apiv3Key',
        'mch_secret_key',
        'mch_secret_cert',
        'mch_public_cert_path',
        'serial_no',
        'notify_url',
        'mp_app_id',
        'mini_app_id',
        'app_id',
      ],
    },
    componentProps: {
      checkedValue: '1',
      unCheckedValue: '0',
      checkedChildren: '是',
      unCheckedChildren: '否',
    },
    fieldName: 'status',
    label: '是否开启',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'mch_id',
    label: '商户号',
    rules: 'required',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'apiv3Key',
    label: 'APIv3key',
    rules: 'required',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'mch_secret_key',
    label: '商户秘钥',
    rules: 'required',
  },
  {
    component: 'Upload',
    defaultValue: '',
    componentProps: {
      type: 'file',
      multiple: false,
    },
    fieldName: 'mch_secret_cert',
    label: '商户私钥',
    rules: 'required',
  },
  {
    component: 'Upload',
    defaultValue: '',
    componentProps: {
      type: 'file',
      multiple: false,
    },
    fieldName: 'mch_public_cert_path',
    label: '商户公钥证书',
    rules: 'required',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'serial_no',
    label: '证书序列号',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'notify_url',
    label: '回调url',
    rules: 'required',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'mp_app_id',
    label: '公众号APPID',
    rules: 'required',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'mini_app_id',
    label: '小程序APPID',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'app_id',
    label: 'APP的APPID',
  },
];

export const alipayScheam = [
  {
    component: 'Switch',
    defaultValue: '',
    componentProps: {
      checkedValue: '1',
      unCheckedValue: '0',
      checkedChildren: '是',
      unCheckedChildren: '否',
    },
    fieldName: 'status',
    label: '是否开启',
    dependencies: {
      trigger: (values: any) => {
        mergeValues.value.config.alipay.default = {
          ...mergeValues.value.config.alipay.default,
          ...values,
        };
      },
      // 随意一个字段改变时，都会触发
      triggerFields: [
        'status',
        'app_id',
        'app_secret_cert',
        'app_public_cert_path',
        'alipay_public_cert_path',
        'alipay_root_cert_path',
        'return_url',
        'notify_url',
      ],
    },
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'app_id',
    label: 'APPID',
    rules: 'required',
  },
  {
    component: 'Textarea',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'app_secret_cert',
    label: '应用私钥',
    rules: 'required',
  },
  {
    component: 'Upload',
    defaultValue: '',
    componentProps: {
      type: 'file',
      multiple: false,
    },
    fieldName: 'app_public_cert_path',
    label: '应用公钥证书',
    rules: 'required',
  },
  {
    component: 'Upload',
    defaultValue: '',
    componentProps: {
      type: 'file',
      multiple: false,
    },
    fieldName: 'alipay_public_cert_path',
    label: '支付宝公钥证书',
    rules: 'required',
  },
  {
    component: 'Upload',
    defaultValue: '',
    componentProps: {
      type: 'file',
      multiple: false,
    },
    fieldName: 'alipay_root_cert_path',
    label: '支付宝根证书',
    rules: 'required',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'return_url',
    label: 'return_url',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'notify_url',
    label: '回调url',
  },
];

export const unipayScheam = [
  {
    component: 'Switch',
    defaultValue: '0',
    componentProps: {
      checkedValue: '1',
      unCheckedValue: '0',
      checkedChildren: '是',
      unCheckedChildren: '否',
    },
    fieldName: 'status',
    label: '是否开启',
    dependencies: {
      trigger: (values: any) => {
        mergeValues.value.config.unipay.default = {
          ...mergeValues.value.config.unipay.default,
          ...values,
        };
      },
      // 随意一个字段改变时，都会触发
      triggerFields: [
        'status',
        'mch_id',
        'mch_cert_password',
        'mch_cert_path',
        'unipay_public_cert_path',
        'return_url',
        'notify_url',
      ],
    },
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'mch_id',
    label: '商户号',
    rules: 'required',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'mch_cert_password',
    label: '商户公私钥密码',
    rules: 'required',
  },
  {
    component: 'Upload',
    defaultValue: '',
    componentProps: {
      type: 'file',
      multiple: false,
    },
    fieldName: 'mch_cert_path',
    label: '商户公私钥',
    rules: 'required',
  },
  {
    component: 'Upload',
    defaultValue: '',
    componentProps: {
      type: 'file',
      multiple: false,
    },
    fieldName: 'unipay_public_cert_path',
    label: '银联公钥证书',
    rules: 'required',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'return_url',
    label: 'return_url',
  },
  {
    component: 'Input',
    defaultValue: '',
    componentProps: {
      placeholder: '请输入',
    },
    fieldName: 'notify_url',
    label: '回调url',
  },
];
